variable = {
	entity = true,
	__entity = {
	},
}
library = {
	_entity = {
	},
}

for k,v in pairs{
	"BoundingRadius",
	"CallOnRemove",
	//"DeleteOnRemove",
	//"DispatchTraceAttack",
	//"DontDeleteOnRemove",
	//"DropToFloor",
	"EmitSound",
	"EyeAngles",
	"EyePos",
	"GetAngles",
	"GetClass",
	"GetCollisionGroup",
	"GetColor",
	"GetForward",
	//"GetKeyValues",
	"GetLocalAngles",
	"GetLocalPos",
	"GetMaterial",
	"GetMaxHealth",
	"GetModel",
	"GetMoveCollide",
	"GetMoveType",
	"GetName",
	"GetPos",
	"GetRight",
	"GetSkin",
	"GetSolid",
	//"GetUnFreezable",
	"GetUp",
	"GetVelocity",
	"Health",
	"IsConstrained",
	"IsOnFire",
	"IsOnGround",
	"IsPlayer",
	"IsPlayerHolding",
	"IsValid",
	"IsVehicle",
	"IsWeapon",
	"IsWorld",
	"LocalToWorld",
	"LocalToWorldAngles",
	"NearestPoint",
	"OBBCenter",
	"OBBMaxs",
	"OBBMins",
	"OnGround",
	"PhysWake",
	"Remove",
	"RemoveCallOnRemove",
	//"SetColor", //Not like it works without SetRenderMode
	"SetGravity",
	//"SetMaterial",
	"StopLoopingSound",
	"StopSound",
	"Visible",
	"VisibleVec",
	"WaterLevel",
	"WorldSpaceAABB",
	"WorldToLocal",
	"WorldToLocalAngles",
} do
	library._entity[v] = [[function(nent,...)
	local ent = __entity.GetEnt(nent)
	if ent then
		return ent:]]..v..[[(unpack(arg))
	end
end]]
end

for k,v in pairs{
	"AddAngleVelocity",
	"AddVelocity",
	"ApplyForceCenter",
	"ApplyForceOffset",
	"CalculateForceOffset",
	"CalculateVelocityOffset",
	"EnableMotion",
	"GetAngle",
	"GetAngles",
	"GetAngleVelocity",
	"GetDamping",
	"GetEnergy",
	"GetInertia",
	"GetInvInertia",
	"GetInvMass",
	"GetMass",
	"GetMassCenter",
	"GetMaterial",
	"GetPos",
	"GetRotDamping",
	"GetSpeedDamping",
	"GetVelocity",
	"GetVolume",
	"IsAsleep",
	"IsMoveable",
	"IsPenetrating",
	"IsValid",
	"LocalToWorld",
	"LocalToWorldVector",
	"SetAngleDragCoefficient",
	"SetBuoyancyRatio",
	"SetDamping",
	"SetDragCoefficient",
	"Wake",
	"WorldToLocal",
	"WorldToLocalVector",
} do
	library._entity["Phys"..v] = [[function(nent,...)
	local ent = __entity.GetEnt(nent)
	if not ent then
		return
	end
	local phys = ent:GetPhysicsObject()
	if phys:IsValid() then
		return phys:]]..v..[[(unpack(arg))
	end
end]]
end

execute = [[
	__entity = {}
	__entity.GetNent = function(ent)
		local out = {}
		if not (ent and IsEntity(ent) and ent:IsValid() and _G.luachip.playerAccess(player.GetByUniqueID(_pl) or _pl,ent,ent)) then
			out.num = -1
		else
			out.num = ent:EntIndex()
		end
		
		local meta = {
			__index = _entity,
			__newindex = ErrorNoHalt
		}
		setmetatable(out,meta)
		
		return out
	end
	__entity.GetEnt = function(nent)
		local ent = ents.GetByIndex(nent.num)
		if IsEntity(ent) and ent:IsValid() then
			return ent
		end
	end
	
	entity = __entity.GetNent(self)
]]